<template>
  <div>
    <template v-if="isImageFile">
      <img :src="filePath" alt="图片预览" style="max-width: 100%; height: auto;">
    </template>
    <template v-else>
      <p>PDF文件无法直接预览，请点击下方链接下载。</p>
      <a :href="filePath" download target="_blank">点击下载</a>
    </template>
  </div>
</template>

<script>
export default {
  computed: {
    filePath() {
      return this.$route.params.filePath;
    },
    isImageFile() {
      const extension = this.filePath.split('.').pop().toLowerCase();
      return extension === 'png' || extension === 'jpg' || extension === 'jpeg'; 
    }
  }
}  
</script>
